package com.gxgeek.javabasic.ClassLoader;

import java.io.File;
import java.net.URL;
import java.util.List;
import java.util.stream.Stream;

/**
 * Created by gx on 2017/7/5.
 */
public class Test {
    public static void main(String [] args) {
        //输出ClassLoaderText的类加载器名称
        System.out.println("ClassLoaderText类的加载器的名称:"+Test.class.getClassLoader().getClass().getName());
        System.out.println("System类的加载器的名称:"+System.class.getClassLoader());
        System.out.println("Stream类的加载器的名称:"+Stream.class.getClassLoader());
        System.out.println("List类的加载器的名称:"+List.class.getClassLoader());


        ClassLoader cl = Test.class.getClassLoader();

        while (cl != null) {
            System.out.println(cl + "'s parent ClassLoader is " + cl.getParent());
            cl = cl.getParent();
        }

        // 也可通过 System.getProperty("sun.boot.class.path" 获取
        URL[] urls = sun.misc.Launcher.getBootstrapClassPath().getURLs();
        for (int i = 0; i < urls.length; i++) {
            System.out.println(urls[i].toExternalForm());
        }

        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~");
        String paths = System.getProperty("java.ext.dirs");

        String [] pathList = paths.split(File.pathSeparator);

        for(String path : pathList) {
            System.out.println(path);
        }
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~");

        String paths_1 = System.getProperty("java.class.path");

        String [] pathList_1 = paths_1.split(File.pathSeparator);

        for(String path : pathList_1) {
            System.out.println(path);
        }


    }


}
